//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.orphan.supplier.controller;

import com.orphan.supplier.po.DeliveryInfo;
import com.orphan.supplier.po.ListInfo;
import com.orphan.supplier.service.IDeliveryInfoService;
import java.util.List;
import javax.annotation.Resource;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/delivery")
public class DeliveryInfoController {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @Resource
    private IDeliveryInfoService iDeliveryInfoService;

    public DeliveryInfoController() {
    }

    @GetMapping("/addInfo/{deliveryAmount}/{tenderNumber}")
    public ListInfo addInfo( @PathVariable("deliveryAmount") int deliveryAmount, @PathVariable("tenderNumber") String tenderNumber) {
        ListInfo b = this.iDeliveryInfoService.addInfo(deliveryAmount, tenderNumber);
        com.orphan.util.dto.ListInfo a = new com.orphan.util.dto.ListInfo();

        BeanUtils.copyProperties(b,a);

        a.setGoodsTag(1);
        rabbitTemplate.convertAndSend("directSupplierExchange","goodsSupplier",a);
        return b;
    }

    @GetMapping("/list")
    public List<DeliveryInfo> list() {
        return this.iDeliveryInfoService.list();
    }

    @GetMapping("/thisInfo/{username}")
    public List<DeliveryInfo> thisInfo(@PathVariable("username") String username) {
        return this.iDeliveryInfoService.thisInfo(username);
    }

    @GetMapping("/tenderInfo/{tenderNumber}")
    public List<DeliveryInfo> tenderInfo(@PathVariable("tenderNumber") String tenderNumber) {
        return this.iDeliveryInfoService.tenderInfo(tenderNumber);
    }
}
